using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Spec.Dto;
using JTZY.Model.Spec;
using JTZY.Service.Spec.ISpecService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2024-11-01
namespace JTZY.Admin.WebApi.Controllers.Spec
{
    /// <summary>
    /// 商品类型属性表
    /// </summary>
    [Verify]
    [Route("spec/Corecmsgoodstypespec")]
    public class CorecmsgoodstypespecController : BaseController
    {
        /// <summary>
        /// 商品类型属性表接口
        /// </summary>
        private readonly ICorecmsgoodstypespecService _CorecmsgoodstypespecService;

        public CorecmsgoodstypespecController(ICorecmsgoodstypespecService CorecmsgoodstypespecService)
        {
            _CorecmsgoodstypespecService = CorecmsgoodstypespecService;
        }

        /// <summary>
        /// 查询商品类型属性表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespec:list")]
        public IActionResult QueryCorecmsgoodstypespec([FromQuery] CorecmsgoodstypespecQueryDto parm)
        {
            var response = _CorecmsgoodstypespecService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询商品类型属性表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespec:query")]
        public IActionResult GetCorecmsgoodstypespec(int Id)
        {
            var response = _CorecmsgoodstypespecService.GetInfo(Id);
            
            var info = response.Adapt<CorecmsgoodstypespecDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加商品类型属性表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespec:add")]
        [Log(Title = "商品类型属性表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsgoodstypespec([FromBody] CorecmsgoodstypespecDto parm)
        {
            var modal = parm.Adapt<Corecmsgoodstypespec>().ToCreate(HttpContext);

            var response = _CorecmsgoodstypespecService.AddCorecmsgoodstypespec(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新商品类型属性表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespec:edit")]
        [Log(Title = "商品类型属性表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsgoodstypespec([FromBody] CorecmsgoodstypespecDto parm)
        {
            var modal = parm.Adapt<Corecmsgoodstypespec>().ToUpdate(HttpContext);
            var response = _CorecmsgoodstypespecService.UpdateCorecmsgoodstypespec(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除商品类型属性表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespec:delete")]
        [Log(Title = "商品类型属性表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsgoodstypespec([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CorecmsgoodstypespecService.Delete(idArr));
        }

    }
}